var i = 0;
var dhtmlgoodies_tooltip = '';
var dhtmlgoodies_tooltipFlag = false;
var dhtmlgoodies_shadowSize = 3;
var dhtmlgoodies_tooltipShadow = '';
var dhtmlgoodies_tooltipMinWidth = 100;
var dhtmlgoodies_tooltipMaxWidth = 500;
var timeId;
var dhtmlgoodies_iframe = false;
var tooltip_is_msie =
  navigator.userAgent.indexOf('MSIE') >= 0 &&
  navigator.userAgent.indexOf('opera') == -1 &&
  document.all
    ? true
    : false;
var clickFlag = false;
var yPos;
var xPos;
window.document.onmousemove = function(a) {
  a = a || window.event;
  if (a.pageX) {
    yPos = a.pageY;
    xPos = a.pageX;
  } else {
    if (document.body !== null && typeof document.body !== 'undefined') {
      yPos = a.clientY + document.body.scrollTop - document.body.clientTop;
      xPos = a.clientX + document.body.scrollLeft - document.body.clientLeft;
    }
  }
};
function showTooltip(e) {
  if (
    document.body === null ||
    typeof document.body === 'undefined' ||
    i == 0
  ) {
    return;
  }
  clickFlag = true;
  var f = Json.parse('jsonData.' + e);
  var a =
    Math.max(document.body.clientWidth, document.documentElement.clientWidth) -
    20;
  if (!dhtmlgoodies_tooltipFlag) {
    dhtmlgoodies_tooltipShadow = document.createElement('DIV');
    dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
    dhtmlgoodies_tooltip = document.createElement('DIV');
    dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
    document.body.appendChild(dhtmlgoodies_tooltip);
    document.body.appendChild(dhtmlgoodies_tooltipShadow);
    if (tooltip_is_msie) {
      dhtmlgoodies_iframe = document.createElement('IFRAME');
      dhtmlgoodies_iframe.style.backgroundColor = '#FFFFFF';
      dhtmlgoodies_iframe.frameborder = '5';
      dhtmlgoodies_iframe.src = '#';
      dhtmlgoodies_iframe.style.position = 'absolute';
      dhtmlgoodies_iframe.style.zIndex = 100;
      document.body.appendChild(dhtmlgoodies_iframe);
    }
  }
  dhtmlgoodies_tooltipShadow.style.display = 'block';
  dhtmlgoodies_tooltip.style.display = 'block';
  if (tooltip_is_msie) {
    dhtmlgoodies_iframe.style.display = 'block';
  }
  var b = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
  if (navigator.userAgent.toLowerCase().indexOf('safari') >= 0) {
    b = 0;
  }
  dhtmlgoodies_tooltip.style.width = null;
  dhtmlgoodies_tooltip.innerHTML = f;
  var c = xPos + 10;
  dhtmlgoodies_tooltip.style.left = c + 'px';
  if (tooltip_is_msie) {
    dhtmlgoodies_tooltip.style.top = yPos + 20 + b + 'px';
  } else {
    dhtmlgoodies_tooltip.style.top = yPos + 20 + 'px';
  }
  dhtmlgoodies_tooltipShadow.style.left = c + dhtmlgoodies_shadowSize + 'px';
  if (tooltip_is_msie) {
    dhtmlgoodies_tooltipShadow.style.top =
      yPos + 20 + b + dhtmlgoodies_shadowSize + 'px';
  } else {
    dhtmlgoodies_tooltipShadow.style.top =
      yPos + 20 + dhtmlgoodies_shadowSize + 'px';
  }
  if (dhtmlgoodies_tooltip.offsetWidth > dhtmlgoodies_tooltipMaxWidth) {
    dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
  }
  var d = dhtmlgoodies_tooltip.offsetWidth;
  if (d < dhtmlgoodies_tooltipMinWidth) {
    d = dhtmlgoodies_tooltipMinWidth;
  }
  dhtmlgoodies_tooltip.style.width = d + 'px';
  dhtmlgoodies_tooltipShadow.style.height =
    dhtmlgoodies_tooltip.offsetHeight + 'px';
  dhtmlgoodies_tooltipShadow.style.width =
    dhtmlgoodies_tooltip.offsetWidth + 'px';
  if (c + d > a) {
    dhtmlgoodies_tooltip.style.left =
      dhtmlgoodies_tooltipShadow.style.left.replace('px', '') -
      (c + d - a) +
      'px';
    dhtmlgoodies_tooltipShadow.style.left =
      dhtmlgoodies_tooltipShadow.style.left.replace('px', '') -
      (c + d - a) +
      dhtmlgoodies_shadowSize +
      'px';
  }
  if (tooltip_is_msie) {
    dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
    dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
    dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
    dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
  }
}
function hideTooltip() {
  i = 0;
  clickFlag = false;
  if (
    dhtmlgoodies_tooltip !== null &&
    typeof dhtmlgoodies_tooltip !== 'undefined' &&
    +(
      dhtmlgoodies_tooltip.style !== null &&
      typeof dhtmlgoodies_tooltip.style !== 'undefined'
    )
  ) {
    dhtmlgoodies_tooltip.style.display = 'none';
    dhtmlgoodies_tooltipShadow.style.display = 'none';
    if (tooltip_is_msie) {
      dhtmlgoodies_iframe.style.display = 'none';
    }
  }
  if (timeId !== null && typeof timeId !== 'undefined' && timeId != '') {
    clearTimeout(timeId);
  }
}
function showText(a) {
  i = 1;
  timeId = setTimeout(function() {
    showTooltip(a);
  }, 500);
}
function showText2(a) {
  if (!clickFlag) {
    i = 1;
    showTooltip(a);
    i = 0;
    if (timeId !== null && typeof timeId !== 'undefined' && timeId != '') {
      clearTimeout(timeId);
    }
  }
}
function anchorScroll(b) {
  var d = document.getElementsByName(b);
  if (d != null && d.length > 0) {
    var c = d[0];
    var a =
      c.getBoundingClientRect().left +
      (document.body.scrollLeft ||
        (document.documentElement && document.documentElement.scrollLeft));
    var e =
      c.getBoundingClientRect().top +
      (document.body.scrollTop ||
        (document.documentElement && document.documentElement.scrollTop));
    window.scrollTo(a, e - 30);
  }
}
